from app.api import abstract

class Action(abstract.Action):
    
    def _post(self):
        
        wish_ids = self.param("wish_id")
        
        wish = abstract.models.reservation.add(self.param("wish_id", "id"), self.viewer_id)
        
        if not wish: return False
        
        if wish.image != None:
            img_url = abstract.config.IMG_URL + "?id=" + wish_ids + "&nc=" + wish.updated.strftime("%d%m%y%H%M%S")
        else:
            img_url = ""
        
        data = {"wish_id" : wish_ids, "price_from" : wish.price_from, "price_to" : wish.price_to, "owner_id" : wish.owner_id, "title" : wish.title, 
                   "link" : wish.link , "img_url" : img_url, "tags" : wish.tags, "reserved" : True,
                   "reason_id" : wish.reason_id, "status" : wish.status, "updated" : wish.updated.strftime("%d.%m.%y %H:%M:%S")}
        
        return data